package GUI;

import java.awt.FlowLayout;
import java.awt.Image;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;

public class PlaySong extends JFrame {
	
	private JTextField user;
	private JTextField title;
	private JTextField artist;
	private JTextField duration; 
	private JTextField releaseDate;
	private JTextField pricePerPlay;
	private JButton play;
	private JButton pause;
	private JButton stop;
	private JTextArea lyrics;
	private JTextField points;
	
	public PlaySong (){
		this.setTitle("Tralala");
		
		user = new JTextField();
		title = new JTextField();
		artist = new JTextField();
		pricePerPlay = new JTextField();
		duration = new JTextField();
		releaseDate = new JTextField();
		pricePerPlay = new JTextField();
		play = new JButton(new ImageIcon(getClass().getResource("/resources/play.png")));
		pause = new JButton(new ImageIcon(getClass().getResource("/resources/pause.png")));
		stop = new JButton();
		lyrics = new JTextArea("Esto es una cancion");
		points = new JTextField();
		JPanel mainPanel = new JPanel();
		BoxLayout mainBox = new BoxLayout(mainPanel, BoxLayout.X_AXIS);
		mainPanel.setLayout(mainBox);
		mainPanel.add(panelLeft());
		mainPanel.add(panelRight());
		this.add(mainPanel);
		
		
	}
	
	private JPanel panelLeft (){
		JPanel panelLeft = new JPanel();
		BoxLayout boxPrincipal = new BoxLayout(panelLeft, BoxLayout.Y_AXIS);
		panelLeft.setLayout(boxPrincipal);	
		
		JPanel panelUser = new JPanel(new FlowLayout(FlowLayout.LEFT));
		panelUser.setBorder(BorderFactory.createTitledBorder("Users"));
		panelUser.add(user);
		panelLeft.add(panelUser);
		
		JPanel panelSongInfo = new JPanel();
		BoxLayout box = new BoxLayout(panelSongInfo, BoxLayout.Y_AXIS);
		panelSongInfo.setLayout(box);
		
		panelSongInfo.setBorder(BorderFactory.createTitledBorder("Song information"));
		JPanel temp1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
		temp1.add(new JLabel("Title: "));
		temp1.add(title);
		panelSongInfo.add(temp1);
		JPanel temp2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
		temp2.add(new JLabel("Artist: "));
		temp2.add(artist);
		panelSongInfo.add(temp2);
		JPanel temp3 = new JPanel(new FlowLayout(FlowLayout.LEFT));
		temp3.add(new JLabel("Price per play: "));
		temp3.add(pricePerPlay);
		panelSongInfo.add(temp3);
		JPanel temp4 = new JPanel(new FlowLayout(FlowLayout.LEFT));
		temp4.add(new JLabel("Duration: "));
		temp4.add(duration);
		panelSongInfo.add(temp4);
		panelLeft.add(panelSongInfo);
		
		return panelLeft;
		
	}
	
	private JPanel panelRight(){
		JPanel pr = new JPanel();
		BoxLayout boxLayout = new BoxLayout(pr, BoxLayout.Y_AXIS);
		pr.setLayout(boxLayout);
		
		
		JPanel panelPoints = new JPanel();
		panelPoints.setLayout(new FlowLayout(FlowLayout.LEFT));
		panelPoints.setBorder(BorderFactory.createTitledBorder("Points"));
		panelPoints.add(points);
		pr.add(panelPoints);
		
		JPanel panelLyrics = new JPanel();
		panelLyrics.setBorder(BorderFactory.createTitledBorder("Lyrics"));
		panelLyrics.add(lyrics);
		pr.add(panelLyrics);
		
		JPanel panelButtons = new JPanel();
		panelButtons.setBorder(BorderFactory.createEmptyBorder(-5, -5, -5, -5));
		panelButtons.add(pause);
		panelButtons.add(play);
		panelButtons.add(stop);
		pr.add(panelButtons);
		return pr;
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try {
			for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
				if ("Nimbus".equals(info.getName())) {
					UIManager.setLookAndFeel(info.getClassName());
					break;
				}
			}
		} catch (Exception e) {
		}
		PlaySong p = new PlaySong();
		p.setVisible(true);
		p.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		p.setSize(800, 600);
	}

}
